<?php

class CommonCategoryMethods {

    private $data = array();

    public function makeDropDown($parents) {
        global $data;
        $data = array();
        $data[''] = '-- Select Parent Category --';
        foreach ($parents as $parent) {
            if ($parent->status == '1') {                
                $data[$parent->id] = $parent->page_name;
                $this->subDropDown($parent->children);
            }
        }       
        return $data;
    }

    public function subDropDown($children, $space = '---') {
        global $data;
        foreach ($children as $child) {
            if ($child->status == '1') {
                $data[$child->id] = $space . $child->page_name;
                $this->subDropDown($child->children, $space . '---');
            }
        }
    }

}

?>
